package mya.mes.mdc.logic.alarm.tag;

import mya.mes.mdc.logic.plc.PlcTagDefUpdater;
import mya.mes.mdc.model.alarm.MdcAlarmType;
import mya.mes.mdc.share.vo.MdcOptions;

public class AlarmTypeUpdater extends PlcTagDefUpdater<MdcAlarmType> {
    public AlarmTypeUpdater() {
        super(MdcAlarmType.class);
    }

    @Override
    protected void processCreate(MdcOptions mdcOptions, MdcAlarmType plcTagType) {
        updateWeixinInfo(mdcOptions, plcTagType);
    }

    @Override
    protected void processUpdate(MdcOptions mdcOptions, MdcAlarmType plcTagType) {
        updateWeixinInfo(mdcOptions, plcTagType);
    }

    private void updateWeixinInfo(MdcOptions mdcOptions, MdcAlarmType alarmType) {

        if (alarmType.getNeedSendToPerson() == null)
            alarmType.setNeedSendToPerson(Boolean.TRUE);

        if (alarmType.getNeedSendToManager() == null)
            alarmType.setNeedSendToManager(Boolean.FALSE);

        if (alarmType.getTimeWaitToPerson() == null)
            alarmType.setTimeWaitToPerson(mdcOptions.TIME_WAIT_TO_PERSON_DEFAULT);

        if (alarmType.getTimeWaitToManager() == null)
            alarmType.setTimeWaitToManager(mdcOptions.TIME_WAIT_TO_MANAGER_DEFAULT);
    }


}
